﻿#region Opis pliku
//-----------------------------------------------------------------------------
// Turret.cs
// Autor: Jan Fraś
// 30.10.2012
//-----------------------------------------------------------------------------
#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
namespace pogra
{
    /// <summary>
    /// wieżyczka czołgu. 
    /// Posiada swoje punkty życia, odpowiada za miotanie pocisków.
    /// </summary>
    class Turret
    {
        int hp;
        Texture2D tex;
        Tank owner;
        Rectangle cliprect;
        float rotation;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="tex"></param>
        /// <param name="owner"></param>
        /// <param name="cliprect"></param>
        public Turret(Texture2D tex, Tank owner, Rectangle cliprect)
        {
            this.owner = owner;
            this.tex = tex;
            hp = 100;
            this.cliprect = cliprect;
        }

        public bool Update()
        {
            return true;
        }

        public void Draw(ExtendedSpriteBatch exSpriteBatch)
        {
            Color color;
            if (owner.Health > 0)
                switch (owner.Team)
                {
                    case 1:
                        color = Color.MediumAquamarine;
                        break;
                    case 2:
                        color = Color.OrangeRed;
                        break;
                    default:
                        color = Color.White;
                        break;
                }
            else
                color = Color.Black;


            exSpriteBatch.Draw(tex, owner.Position, cliprect, color, rotation, new Vector2(cliprect.Width,cliprect.Height)/2, 1, SpriteEffects.None, 0.75f);
        }
        
        public float Rotation
        {
            get { return rotation; }
            set { rotation = value; }
        }
    }
            
}
